package com.sjz.chat2_1;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class SecondActivity extends AppCompatActivity {
    private EditText secondText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        secondText=findViewById(R.id.secondText);
        Intent intent= getIntent();  //得到信使 得到intent对象
        String message=intent.getStringExtra("message");
        Log.i("Second",message);
        secondText.setText(message);   //设置值

    }
    public void back1(View v){
        finish();//关闭当前activity
    }


    public void back2(View v){
          int resultCode=3;
          Intent intent=new Intent(this,MainActivity.class);
          String message=secondText.getText().toString();
          intent.putExtra("RESULT",message);
          setResult(resultCode,intent);//设置带返回值的方法
          finish();//关闭当前activity
    }

}